/**

   Heap.h
   ======

   Heap header

**/


#ifndef HEAP_H
#define HEAP_H


/**

   Includes
   --------

   - chunksrv.h  : chunkserver management

**/


#include "chunksrv.h"


/**

   Structure: struct heap
   ----------------------

   Chunkservers heap. Members are:
   - items : chunkservers
   - n     : number of chunk servers
   - max   : max number of chunk server

**/


struct heap
{
  struct chunksrv** items;
  unsigned int n;
  unsigned int max;
  int (*compare)(struct chunksrv*,struct chunksrv*);
};


/**

   Prototypes
   ----------

**/


struct heap* heap_create(unsigned int max,int (*compare)(struct chunksrv*,struct chunksrv*));
void heap_delete(struct heap* heap);
int heap_insert(struct heap* heap, struct chunksrv* cs);
int heap_remove(struct heap* heap, struct chunksrv* cs);
struct chunksrv* heap_extract(struct heap* heap);

#endif
